package reflect;

import java.lang.reflect.Method;

/**
 * 调用有参数的方法
 * @author pc
 *
 */
public class ReflectDemo4 {
	public static void main(String[] args) throws Exception {
		Person p = new Person();
		p.say("大家好！");		
		p.say("张三",22);
		
		Class<?> cls = Class.forName("reflect.Person");
		Object o = cls.newInstance();
		//p.say("大家好!");
		Method m = cls.getMethod("say", String.class);
		m.invoke(o, "哈喽!");
		//p.say("张三",22)
		Method m2 = cls.getMethod("say", String.class,int.class);
		m2.invoke(o, "李四",33);
	}
}











